package com.bjpowernode.controller;

import com.bjpowernode.model.TClueRemark;
import com.bjpowernode.query.ClueRemarkQuery;
import com.bjpowernode.result.R;
import com.bjpowernode.service.ClueRemarkService;
import com.github.pagehelper.PageInfo;
import jakarta.annotation.Resource;
import org.springframework.web.bind.annotation.*;

@RestController
public class ClueRemarkController {

     @Resource
     ClueRemarkService clueRemarkService;
    @PostMapping("/api/clue/remark")
    public R addClueRemark(@RequestBody ClueRemarkQuery clueRemarkQuery,@RequestHeader(value = "Authorization") String jwt){
         //@RequestBody注解接收前端提交过来的json格式的参数
         clueRemarkQuery.setJwt(jwt);
         int save = clueRemarkService.saveClueRemark(clueRemarkQuery);
         return save >= 1 ? R.OK() : R.FAIL();

    }
    @GetMapping("/api/clue/remark")
    public R clueRemarkPage(@RequestParam(value = "current", required = false) Integer current,
                            @RequestParam(value = "clueId") Integer clueId) {
        //required = false表示current参数可以不传；
        //required = true表示current参数必须要传，不传会报错；
        if (current == null) {
            current = 1;
        }
        PageInfo<TClueRemark> pageInfo = clueRemarkService.getClueRemarkByPage(current, clueId);
        return R.OK(pageInfo);
    }

}
